package com.bdqn.controller;

import com.bdqn.pojo.AppInfo;
import com.bdqn.pojo.DevUser;
import com.bdqn.service.AppInfoService;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.Date;

@Controller
@RequestMapping("/app")
public class AppInfoController {


    @Resource
    private AppInfoService appInfoService;


    @RequestMapping(value = "/addApp")
    @ResponseBody
    public Long addsave(HttpSession session, AppInfo appInfo) throws IOException {
        DevUser user=(DevUser)session.getAttribute("user");
        appInfo.setDevid(user.getId());
        appInfo.setCreatedBy(user.getId());
        appInfo.setCreatedTime(new Date());
        return appInfoService.addAppinfo(appInfo);
    }
    @RequestMapping(value = "/shang")
    @ResponseBody
    public Long shang(HttpServletRequest request) throws IOException {
        Integer d=Integer.parseInt( request.getParameter("three"));


        return appInfoService.updZhuang(5L,d);
    }

    @RequestMapping(value = "/xia")
    @ResponseBody
    public Long xia(HttpServletRequest request) throws IOException {
        Integer d=Integer.parseInt( request.getParameter("three"));

        return appInfoService.updZhuang(4L,d);
    }

    @RequestMapping(value = "/dele")
    @ResponseBody
    public Long dele(HttpServletRequest request) throws IOException {
        Integer d=Integer.parseInt( request.getParameter("three"));

        return appInfoService.deleteOne(d);
    }

    @RequestMapping(value = "/updApp")
    @ResponseBody
    public Long updapp(HttpSession session, AppInfo appInfo) throws IOException {
        DevUser user=(DevUser)session.getAttribute("user");

        appInfo.setUpdatedBy(user.getId());
        appInfo.setUpdatedTime(new Date());
        return appInfoService.upd(appInfo);
    }



}
